Skip to content

feat(fleet): multi-role serve list — one daemon, several roles (#6264) - #8394

Merged
dezren39 merged 5 commits into
mainfrom
queue/11452-6264-serve-all
Nov 11, 2026
Merged

dezren39 merged 5 commits into
mainfrom
queue/11452-6264-serve-all

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements #6264: the approved serve-all design from #5698 (option (i), the multicall list, approved by Drew 2026-11-05).

  • feat(fleet): fleet serve <role> [<role> ...] with two or more distinct role tokens runs all of them in ONE process — each role's existing blocking serve loop on its own thread, supervised from main. Every role is capability-checked before anything binds (an unavailable role stubs the whole list at exit 69; no partial starts). A role thread that returns or panics is fatal: the process exits with the role's code (1 if it reported success) and names the role, so the external supervisor (systemd) restarts the unit — no in-process restarter, per the design.
  • The list can express the complete current serve set — queue-broker, secrets-broker, search, proxy — Drew's equivalent-of-all criterion, pinned by the serve_set_covers_every_serve_token test.
  • refactor(fleet-queue) (the design's precondition step): queue_broker::run and secrets_broker::run no longer call std::process::exit on setup failures (home, token files, Turso token/schema, bind); they return the same codes (2/3) to the caller. The standalone bins already exit with the returned code, so single-role behavior is unchanged.
  • Single-role invocations are untouched: a role plus its own tail (search flags, --help after a role) is not a list and keeps the existing per-role paths and argument rules; bare fleet serve stays a usage error; duplicate roles and stray tokens inside a list are usage errors naming the token (the stray-arg class the design called out).
  • Deployment shape unchanged: per-role systemd units remain the default; the list is the one-process alternative the design approved. all sugar and --with-proxy remain deferred per the design (proxy IS a list member here because fleet serve proxy is already a serve-domain role in the current build, and equivalent-of-all requires the full set to be expressible).

Evidence

  • cargo test -p fleet-queue -p fleet: all suites pass, including 4 new unit tests (list parsing, duplicate/stray rejection, single-role non-interference, serve-set completeness).
  • Live demo on the laptop (fresh debug build, fake HOME, loopback binds): fleet serve queue-broker secrets-broker printed "starting 2 roles in one process", both brokers listened (127.0.0.1:14801 / :14800), secrets-broker /health answered ok, queue-broker /health answered its unauthorized gate, and both UDS dual-binds degraded to TCP-only against the live brokers' sockets without disturbing them.
  • Error paths: bare fleet serve usage error; fleet serve queue-broker queue-broker duplicate-role error; a stray token in a list is named in the error.

Merge Danger

Door: two-way. Blast radius: fleet serve dispatch and the two brokers' setup-failure paths. Single-role serve — what every live unit runs — keeps identical behavior and exit codes; the multi-role path only activates on the new list grammar.

@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 01:34
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 84cdf9fb-cf60-4de1-9047-b762053d1981
Commits

Reviewing files that changed from the base of the PR and between 3c42146 and 95e7f93.

Files selected for processing: 4

  • pkgs/fleet/crates/fleet-proxy/src/serve.rs
  • pkgs/fleet/crates/fleet-queue/src/queue_broker.rs
  • pkgs/fleet/crates/fleet-queue/src/secrets_broker.rs
  • pkgs/fleet/crates/fleet/src/main.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T09:25:39.748978Z 95e7f93 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2365578df1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/fleet/crates/fleet/src/main.rs Resolved
Comment thread pkgs/fleet/crates/fleet/src/main.rs Resolved
@dezren39

Copy link
Copy Markdown
Member Author

🤖 Agent note · parked on CI (task 11452, lane code-f)

PR #8394 implements #6264 (design #5698 option (i)): the multi-role serve list, plus the precondition refactor making both brokers' run() return setup failures instead of exiting the process. Verified on the laptop: cargo test -p fleet-queue -p fleet all pass (4 new serve-list unit tests), and a live demo ran fleet serve queue-broker secrets-broker as one process on loopback binds — both brokers answered HTTP, UDS dual-binds degraded to TCP-only against the live brokers without disturbing them.

Parked as a CI wait: checks are pending at head 2365578 with no failures. Resume: when PR #8394 checks complete, merge if green — that lands #6264's acceptance and closes issue #6264 (design record #5698 stays open per its own terms until Drew closes it).

@dezren39 dezren39 added queue/parked Queue task is parked (waiting on CI, time, or an event) status/parked Deliberately paused with a recorded resume condition work/assigned Queue worker lifecycle state labels Nov 11, 2026
repo-worker-code-k added 3 commits November 10, 2026 21:15
… exiting

Precondition for multi-role serve (design #5698 step 2, impl #6264): queue_broker::run and secrets_broker::run called std::process::exit on setup failures (home resolution, token files, Turso token/schema, bind). Every such site now returns the same exit code (2 or 3) to the caller. The standalone bins already exit with the returned code, so single-role behavior is unchanged; a supervisor hosting several roles in one process now sees a role setup failure as that role returning its code.
Implements design #5698 option (i), approved by Drew 2026-11-05: fleet serve <role> [<role> ...] runs two or more roles in one process, each existing blocking serve loop on its own thread under a small supervisor. All roles are capability-checked before anything binds (an unavailable role stubs the whole list at exit 69 — no partial starts); a role thread that returns or panics is fatal, exiting with the role code and naming the role, so the external supervisor restarts the unit.

The list can express the complete current serve set (queue-broker, secrets-broker, search, proxy) — the equivalent-of-all criterion — pinned by serve_set_covers_every_serve_token. Single-role invocations are untouched: a role plus its own tail (search flags, --help) is not a list and keeps the existing per-role paths; bare fleet serve stays a usage error; duplicate roles and stray tokens in a list are usage errors naming the token.
…bounded startup retry for the Turso token

P1: serve list runs the proxy via fleet_proxy::serve::run_cohosted (idle-exit disabled); standalone run() keeps the auto-spawned lifetime. P2: queue_broker resolves the Turso token via resolve_with_startup_retry (250ms backoff, 30s budget) so a cold co-hosted secrets-broker no longer races it into exit 3; two unit tests pin the retry contract.
@dezren39
dezren39 force-pushed the queue/11452-6264-serve-all branch from 2365578 to ebb9019 Compare November 11, 2026 03:21
@dezren39 dezren39 added queue/claimed Queue worker lifecycle state queue/parked Queue task is parked (waiting on CI, time, or an event) status/parked Deliberately paused with a recorded resume condition and removed status/parked Deliberately paused with a recorded resume condition queue/parked Queue task is parked (waiting on CI, time, or an event) queue/claimed Queue worker lifecycle state labels Nov 11, 2026
repo-worker-tmp-code-b added 2 commits November 11, 2026 01:06
@dezren39
dezren39 merged commit e599220 into main Nov 11, 2026
1 of 10 checks passed
@dezren39
dezren39 deleted the queue/11452-6264-serve-all branch November 11, 2026 09:32
@dezren39 dezren39 removed status/parked Deliberately paused with a recorded resume condition queue/parked Queue task is parked (waiting on CI, time, or an event) work/assigned Queue worker lifecycle state labels Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant